package com.yichen.ycapi.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yichen.ycApiCommon.model.entity.User;
import com.yichen.ycApiCommon.service.InnerUserService;
import com.yichen.ycapi.common.ErrorCode;
import com.yichen.ycapi.exception.BusinessException;
import com.yichen.ycapi.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @Author: yichenwu
 * @Date:2024/7/31 0:26
 */
@DubboService
public class InnerUserServiceImpl implements InnerUserService {
    @Resource
    UserService userService;
    @Override
    public User getInvokeUser(String accessKey) {
        // 参数校验
        if (StringUtils.isAnyBlank(accessKey)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        User user = userService.getOne(new QueryWrapper<User>()
                .eq("accessKey", accessKey));
        return user;
    }
}
